package ua.kpi_java_training.tyshchenko.module2.test;

import org.junit.Before;
import org.junit.Test;
import static junit.framework.Assert.*;
import ua.kpi_java_training.tyshchenko.module2.*;

/**
 * @author Vlad Tyshchenko
 * @version 1.0 19 June 2013
 */
public class MovementInFourDirectionsTest {
    int lengthStep;
    Position position;
    MovementInFourDirections movement;

    @Before
    public void setUp() {
        lengthStep = 1;
        position = new Position(new StabRandom(), new Habitat(new StabInputAllData()));
        movement = new MovementInFourDirections(position);
    }

    @Test
    public void testMove() {
        int coordinate = position.getLength();
        movement.move(new StabRandom(1), lengthStep);
        assertEquals("move up (1)", position.getLength(), coordinate - 1);

        coordinate = position.getLength();
        movement.move(new StabRandom(3), lengthStep);
        assertEquals("move down (3)", position.getLength(), coordinate + 1);

        coordinate = position.getWidth();
        movement.move(new StabRandom(0), lengthStep);
        assertEquals("move left (0)", position.getWidth(), coordinate - 1);

        coordinate = position.getWidth();
        movement.move(new StabRandom(2), lengthStep);
        assertEquals("move right (1)", position.getWidth(), coordinate + 1);
    }
}
